package com.gmail.bogatyr.alexander.client.presenter;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.Label;
import net.customware.gwt.presenter.client.EventBus;
import net.customware.gwt.presenter.client.widget.WidgetDisplay;
import net.customware.gwt.presenter.client.widget.WidgetPresenter;

public class TelephoneBookEditPresenter extends WidgetPresenter<TelephoneBookEditPresenter.Display> {

    public TelephoneBookEditPresenter(Display display, EventBus eventBus) {
        super(display, eventBus);
    }

    public interface Display extends WidgetDisplay {
        public Label getTitleLabel();
        public HasValue<String> getNumberTextField();
        public HasValue<String> getNameTextField();
        public HasClickHandlers getSaveButton();
        public HasClickHandlers getCancelButton();
    }
    
    @Override
    protected void onBind() {
        registerHandler(display.getSaveButton().addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                Window.alert("Save and redirect to contact list");
            }
        }));
        registerHandler(display.getCancelButton().addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                Window.alert("Redirect to view contact");
            }
        }));
    }

    @Override
    protected void onUnbind() {
        //nothing
    }

    @Override
    protected void onRevealDisplay() {
        //nothing
    }
}
